Skip to content

Conversation

@igorpecovnik
Copy link
Member

No description provided.

@igorpecovnik igorpecovnik force-pushed the runners branch 30 times, most recently from 9130cfb to 63b9bfd Compare January 7, 2025 17:57
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 2, 2025

Warning

Rate limit exceeded

@igorpecovnik has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 18 minutes and 24 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 9796115 and 49ba35e.

📒 Files selected for processing (1)
  • README.md (1 hunks)

Walkthrough

Adds a new GitHub Actions workflow at .github/workflows/generate-runners-status.yml named "Generate runners status", triggered on push and workflow_dispatch. It defines two jobs: Check (runs on ubuntu-22.04) which verifies the actor is in the "Release manager" team via armbian/actions/team-check@main using ORG_MEMBERS and GITHUB_TOKEN; and build (runs on ubuntu-24.04, needs: Check) which installs jq, paginates the GitHub API using the RUNNERS secret to collect org runners into runners.json, queries NetBox (NETBOX_API, NETBOX_TOKEN) for active user-level runner VMs, gathers per-VM details (name, vCPUs, memory, disk, runners), cross-references runner statuses, and writes an HTML table to GITHUB_STEP_SUMMARY.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested labels

ready to merge

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch runners

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

🧹 Nitpick comments (5)
.github/workflows/generate-runners-status.yml (5)

9-12: Enable concurrency to avoid overlapping runs and inconsistent summaries

Uncomment and set a stable group; cancel in-progress for push to keep latest-only results.

-#concurrency:
-#  group: redirector
-#  cancel-in-progress: false
+concurrency:
+  group: generate-runners-status
+  cancel-in-progress: true

34-39: Pin cache-apt action and consider a hard timeout

Lock the action to a commit SHA and cap runtime to prevent hanging builds.

-uses: awalsh128/cache-apt-pkgs-action@latest
+uses: awalsh128/cache-apt-pkgs-action@<commit-sha>

You can also add a per-job timeout:

   build:
     name: "Get self hosted runners status"
     runs-on: ubuntu-24.04
     needs: Check
+    timeout-minutes: 15

3-8: Optional: re-enable a schedule for up-to-date status

If you want an always-fresh overview, re-enable the hourly cron (or daily) and keep workflow_dispatch.

-#  schedule:
-#    - cron: '0 * * * *'   # Run every hour
+  schedule:
+    - cron: '0 * * * *'   # Run every hour

40-74: General shell hardening and minor nits

  • Add set -Eeuo pipefail (already shown above).
  • Quote all variables when echoed/printf.
  • Replace useless use of cat with direct jq reads.

Example:

-                  INFO=$(cat runners.json | jq -r '...')
+                  INFO=$(jq -r '...' runners.ndjson)

56-59: Confirm slug filter usage; optional -sS flag and empty-state guard
NetBox’s /virtualization/virtual-machines/?role=<slug> endpoint accepts slug values (e.g. role=userlevel-runner), so no change is needed to the filter. Optionally, replace curl -s with curl -sS to surface HTTP errors and add after capturing $SERVERS:

if [[ -z "$SERVERS" ]]; then
  echo "<tr><td colspan=5><i>No active user-level runners found.</i></td></tr>" >> "$GITHUB_STEP_SUMMARY"
fi

This ensures any empty result set is handled gracefully.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 965b700 and 8446899.

📒 Files selected for processing (1)
  • .github/workflows/generate-runners-status.yml (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Get from Armbian Jira

@igorpecovnik igorpecovnik force-pushed the runners branch 6 times, most recently from 92e9417 to ad7bfa0 Compare September 2, 2025 12:45
@igorpecovnik igorpecovnik changed the title Display runners status Display self hosted runners status Sep 2, 2025
@igorpecovnik igorpecovnik merged commit 11fe3e7 into main Sep 2, 2025
@igorpecovnik igorpecovnik deleted the runners branch September 2, 2025 20:54
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

♻️ Duplicate comments (2)
.github/workflows/generate-runners-status.yml (2)

3-8: Restrict triggers and add least-privilege permissions

Limit push to main to avoid unneeded runs; explicitly scope GITHUB_TOKEN.

 on:
   push:
+    branches:
+      - main
   schedule:
     - cron: '0 * * * *'   # Run every hour
   workflow_dispatch:   # Manually triggered via GitHub Actions UI
+
+permissions:
+  actions: read
+  contents: read

21-26: Pin third‑party actions by commit SHA

Avoid floating refs (@main) for supply‑chain safety.

-uses: armbian/actions/team-check@main
+# TODO: replace <commit-sha> with audited immutable commit
+uses: armbian/actions/team-check@<commit-sha>
🧹 Nitpick comments (4)
.github/workflows/generate-runners-status.yml (4)

9-12: Enable concurrency to avoid overlapping hourly runs

Prevent multiple scheduled executions from piling up.

-#concurrency:
-#  group: redirector
-#  cancel-in-progress: false
+concurrency:
+  group: generate-runners-status
+  cancel-in-progress: true

40-48: Redundant GH_TOKEN assignment

You set GH_TOKEN in env and again inside the script. Keep one.

-      - name: "Get runners from ORG"
-        env:
-          GH_TOKEN: ${{ secrets.RUNNERS }}
-        run: |
-
-          GH_TOKEN=${{ secrets.RUNNERS }}
+      - name: "Get runners from ORG"
+        env:
+          GH_TOKEN: ${{ secrets.RUNNERS }}
+        run: |

82-87: Potential NetBox pagination gap

limit=500 may truncate results. Consider following next if present.

-          curl -s \
+          curl -sS \
             -H "Authorization: Token ${NETBOX_TOKEN}" \
             -H "Accept: application/json; indent=4" \
-            "${NETBOX_API}/virtualization/virtual-machines/?limit=500&name__empty=false&tag=github-runner&status=active" \
+            "${NETBOX_API}/virtualization/virtual-machines/?limit=500&name__empty=false&tag=github-runner&status=active" \
             > "$nb_json"
+# TODO: If nb_json has .next, iterate and merge .results

134-139: Quote $GITHUB_STEP_SUMMARY everywhere

Minor, but consistent quoting avoids surprises.

           printf "<tr><th colspan=2 align=right>Totals:</th><th align=right>%d</th><th align=right>%d</th><th align=right>%d</th><th align=right>%d</th></tr>\n" \
-            "$total_cpu" "$total_mem_gb" "$total_storage_gb" "$total_runners" >> $GITHUB_STEP_SUMMARY
+            "$total_cpu" "$total_mem_gb" "$total_storage_gb" "$total_runners" >> "$GITHUB_STEP_SUMMARY"
 
-          echo "</table>" >> $GITHUB_STEP_SUMMARY
+          echo "</table>" >> "$GITHUB_STEP_SUMMARY"
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between e8fdc1f and 9796115.

📒 Files selected for processing (1)
  • .github/workflows/generate-runners-status.yml (1 hunks)
🔇 Additional comments (1)
.github/workflows/generate-runners-status.yml (1)

98-107: Verify label vs name for runner prefix

You switched from NAME-XX to LABELS-XX. Confirm this matches actual configured runner names to avoid false “offline”.

Comment on lines +15 to +27
Check:

name: "Check permissions"
runs-on: "ubuntu-22.04"
steps:

- name: "Check permissions"
uses: armbian/actions/team-check@main
with:
ORG_MEMBERS: ${{ secrets.ORG_MEMBERS }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TEAM: "Release manager"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Scheduled runs will always fail the Check job

On schedule, the actor is github-actions[bot], not a human team member, so team-check fails and blocks build. Gate Check to non-scheduled events (or invert needs on build).

 Check:
+  if: github.event_name != 'schedule'
   name: "Check permissions"
   runs-on: "ubuntu-22.04"
   steps:
     - name: "Check permissions"
-      uses: armbian/actions/team-check@main
+      uses: armbian/actions/team-check@main
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
Check:
name: "Check permissions"
runs-on: "ubuntu-22.04"
steps:
- name: "Check permissions"
uses: armbian/actions/team-check@main
with:
ORG_MEMBERS: ${{ secrets.ORG_MEMBERS }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TEAM: "Release manager"
Check:
if: github.event_name != 'schedule'
name: "Check permissions"
runs-on: "ubuntu-22.04"
steps:
- name: "Check permissions"
uses: armbian/actions/team-check@main
with:
ORG_MEMBERS: ${{ secrets.ORG_MEMBERS }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TEAM: "Release manager"
🤖 Prompt for AI Agents
.github/workflows/generate-runners-status.yml around lines 15-27: the scheduled
workflow runs as github-actions[bot] so the team-check step (which verifies a
human team membership) will always fail on schedule; to fix, gate the Check
job/step so it does not run for scheduled events by adding a condition like if:
${{ github.event_name != 'schedule' }} (apply to the job or the specific step),
or alternatively adjust job dependencies so the build does not need the Check
job for schedule-triggered runs.

Comment on lines +34 to +39
- name: "Install dependencies: jq"
uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: jq
version: 1.0

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Avoid @latest; either pin by SHA or use apt-get directly

Pin the action or switch to native apt for simplicity.

-      - name: "Install dependencies: jq"
-        uses: awalsh128/cache-apt-pkgs-action@latest
-        with:
-          packages: jq
-          version: 1.0
+      - name: "Install jq"
+        run: |
+          sudo apt-get update
+          sudo apt-get install -y jq
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- name: "Install dependencies: jq"
uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: jq
version: 1.0
- name: "Install jq"
run: |
sudo apt-get update
sudo apt-get install -y jq
🤖 Prompt for AI Agents
.github/workflows/generate-runners-status.yml around lines 34-39: the workflow
currently uses the third-party action with @latest which is not pinned; either
pin the action to a specific commit SHA (e.g. replace @latest with
@<commit-sha>) to ensure reproducible builds, or remove the action and install
jq directly using native apt in a run step (e.g. run: sudo apt-get update &&
sudo apt-get install -y jq) and remove the uses/with block.

Comment on lines +49 to +55
tmp="$(mktemp -d)"
trap 'rm -rf "$tmp"' EXIT

runners_nd="$tmp/runners.ndjson"
out_html="$tmp/runners_summary.html"
: > "$runners_nd"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Harden script execution

Enable strict mode; drop unused out_html var.

           tmp="$(mktemp -d)"
           trap 'rm -rf "$tmp"' EXIT
 
           runners_nd="$tmp/runners.ndjson"
-          out_html="$tmp/runners_summary.html"
           : > "$runners_nd"
+          set -Eeuo pipefail
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
tmp="$(mktemp -d)"
trap 'rm -rf "$tmp"' EXIT
runners_nd="$tmp/runners.ndjson"
out_html="$tmp/runners_summary.html"
: > "$runners_nd"
tmp="$(mktemp -d)"
trap 'rm -rf "$tmp"' EXIT
runners_nd="$tmp/runners.ndjson"
: > "$runners_nd"
set -Eeuo pipefail
🤖 Prompt for AI Agents
.github/workflows/generate-runners-status.yml around lines 49 to 55: enable
strict shell mode and remove the unused out_html variable; add a safe
shebang/session options by inserting set -euo pipefail and IFS=$'\n\t' near the
top of the script (or before this block) so the script fails fast on
errors/unset variables and handles word splitting safely, and delete the
out_html="$tmp/runners_summary.html" assignment since out_html is unused; keep
tmp="$(mktemp -d)" and the trap as-is and ensure the rest of the script
references "$runners_nd" only.

Comment on lines +56 to +71
# Fetch ALL GitHub org runners (prefer gh; fallback to curl)
if command -v gh >/dev/null 2>&1; then
gh api \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
--paginate /orgs/armbian/actions/runners \
-q '.runners[]' > "$runners_nd"
else
curl -fsSL \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${GH_TOKEN}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"https://api.github.com/orgs/armbian/actions/runners?per_page=100" \
| jq -c '.runners[]' > "$runners_nd"
fi

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Curl fallback fetches only first page (misses >100 runners)

Paginate until empty or Link header exhausted.

         else
-          curl -fsSL \
-            -H "Accept: application/vnd.github+json" \
-            -H "Authorization: Bearer ${GH_TOKEN}" \
-            -H "X-GitHub-Api-Version: 2022-11-28" \
-            "https://api.github.com/orgs/armbian/actions/runners?per_page=100" \
-            | jq -c '.runners[]' > "$runners_nd"
+          page=1
+          while :; do
+            resp="$(curl -fsSL \
+              -H "Accept: application/vnd.github+json" \
+              -H "Authorization: Bearer ${GH_TOKEN}" \
+              -H "X-GitHub-Api-Version: 2022-11-28" \
+              "https://api.github.com/orgs/armbian/actions/runners?per_page=100&page=${page}")"
+            count="$(jq '.runners | length' <<<"$resp")"
+            [[ "${count}" -eq 0 ]] && break
+            jq -c '.runners[]' <<<"$resp" >> "$runners_nd"
+            page=$((page+1))
+          done
         fi
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# Fetch ALL GitHub org runners (prefer gh; fallback to curl)
if command -v gh >/dev/null 2>&1; then
gh api \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
--paginate /orgs/armbian/actions/runners \
-q '.runners[]' > "$runners_nd"
else
curl -fsSL \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${GH_TOKEN}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"https://api.github.com/orgs/armbian/actions/runners?per_page=100" \
| jq -c '.runners[]' > "$runners_nd"
fi
# Fetch ALL GitHub org runners (prefer gh; fallback to curl)
if command -v gh >/dev/null 2>&1; then
gh api \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
--paginate /orgs/armbian/actions/runners \
-q '.runners[]' > "$runners_nd"
else
page=1
while :; do
resp="$(curl -fsSL \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${GH_TOKEN}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"https://api.github.com/orgs/armbian/actions/runners?per_page=100&page=${page}")"
count="$(jq '.runners | length' <<<"$resp")"
[[ "${count}" -eq 0 ]] && break
jq -c '.runners[]' <<<"$resp" >> "$runners_nd"
page=$((page+1))
done
fi
🤖 Prompt for AI Agents
.github/workflows/generate-runners-status.yml around lines 56 to 71: the curl
fallback currently fetches only the first page (up to 100 runners) and will miss
additional pages; change the fallback to loop and paginate until no more pages
(either by following the Link header or incrementing a page counter with
?per_page=100&page=N) and append each page's runners to the output file,
preserving the same headers/authorization and using jq to extract '.runners[]'
for each page; ensure the loop breaks when the response has no runners or when
the Link header indicates no "next" link.

Comment on lines +88 to +101
# Render to stdout and to HTML file
echo "<table border=0>" >> $GITHUB_STEP_SUMMARY
echo "<tr><th align=left>Server</th><th align=left>Runner label</th><th align=right>CPU cores</th><th align=right>Memory GB</th><th align=right>Storage GB</th><th align=right>Runners</th></tr>" >> $GITHUB_STEP_SUMMARY

# init totals
total_cpu=0
total_mem_gb=0
total_storage_gb=0
total_runners=0

while IFS=$'\t' read -r NAME CPU MEM_MB DISK_GB RUNNERS LABELS ID; do
CALC_MEM=$(( (MEM_MB + 512) / 1024 ))
printf "<tr><td>%s</td><td>%s</td><td align=right>%d</td><td align=right>%d</td><td align=right>%d</td><td align=right>%d</td></tr>\n" \
"$NAME" "$LABELS" "$CPU" "$CALC_MEM" "$DISK_GB" "$RUNNERS" >> $GITHUB_STEP_SUMMARY
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Escape HTML and quote file path

Names/labels from NetBox may contain special chars; escape to avoid broken markup. Also quote $GITHUB_STEP_SUMMARY.

-          echo "<table border=0>"  >> $GITHUB_STEP_SUMMARY
-          echo "<tr><th align=left>Server</th><th align=left>Runner label</th><th align=right>CPU cores</th><th align=right>Memory GB</th><th align=right>Storage GB</th><th align=right>Runners</th></tr>"  >> $GITHUB_STEP_SUMMARY
+          echo "<table border=0>"  >> "$GITHUB_STEP_SUMMARY"
+          echo "<tr><th align=left>Server</th><th align=left>Runner label</th><th align=right>CPU cores</th><th align=right>Memory GB</th><th align=right>Storage GB</th><th align=right>Runners</th></tr>"  >> "$GITHUB_STEP_SUMMARY"
@@
-            printf "<tr><td>%s</td><td>%s</td><td align=right>%d</td><td align=right>%d</td><td align=right>%d</td><td align=right>%d</td></tr>\n" \
-              "$NAME" "$LABELS" "$CPU" "$CALC_MEM" "$DISK_GB" "$RUNNERS" >> $GITHUB_STEP_SUMMARY
+            esc_name=$(jq -Rr @html <<<"$NAME")
+            esc_labels=$(jq -Rr @html <<<"$LABELS")
+            printf "<tr><td>%s</td><td>%s</td><td align=right>%d</td><td align=right>%d</td><td align=right>%d</td><td align=right>%d</td></tr>\n" \
+              "$esc_name" "$esc_labels" "$CPU" "$CALC_MEM" "$DISK_GB" "$RUNNERS" >> "$GITHUB_STEP_SUMMARY"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# Render to stdout and to HTML file
echo "<table border=0>" >> $GITHUB_STEP_SUMMARY
echo "<tr><th align=left>Server</th><th align=left>Runner label</th><th align=right>CPU cores</th><th align=right>Memory GB</th><th align=right>Storage GB</th><th align=right>Runners</th></tr>" >> $GITHUB_STEP_SUMMARY
# init totals
total_cpu=0
total_mem_gb=0
total_storage_gb=0
total_runners=0
while IFS=$'\t' read -r NAME CPU MEM_MB DISK_GB RUNNERS LABELS ID; do
CALC_MEM=$(( (MEM_MB + 512) / 1024 ))
printf "<tr><td>%s</td><td>%s</td><td align=right>%d</td><td align=right>%d</td><td align=right>%d</td><td align=right>%d</td></tr>\n" \
"$NAME" "$LABELS" "$CPU" "$CALC_MEM" "$DISK_GB" "$RUNNERS" >> $GITHUB_STEP_SUMMARY
# Render to stdout and to HTML file
echo "<table border=0>" >> "$GITHUB_STEP_SUMMARY"
echo "<tr><th align=left>Server</th><th align=left>Runner label</th><th align=right>CPU cores</th><th align=right>Memory GB</th><th align=right>Storage GB</th><th align=right>Runners</th></tr>" >> "$GITHUB_STEP_SUMMARY"
# init totals
total_cpu=0
total_mem_gb=0
total_storage_gb=0
total_runners=0
while IFS=$'\t' read -r NAME CPU MEM_MB DISK_GB RUNNERS LABELS ID; do
CALC_MEM=$(( (MEM_MB + 512) / 1024 ))
esc_name=$(jq -Rr @html <<<"$NAME")
esc_labels=$(jq -Rr @html <<<"$LABELS")
printf "<tr><td>%s</td><td>%s</td><td align=right>%d</td><td align=right>%d</td><td align=right>%d</td><td align=right>%d</td></tr>\n" \
"$esc_name" "$esc_labels" "$CPU" "$CALC_MEM" "$DISK_GB" "$RUNNERS" >> "$GITHUB_STEP_SUMMARY"
🤖 Prompt for AI Agents
In .github/workflows/generate-runners-status.yml around lines 88-101, the NAME
and LABELS values from NetBox are not HTML-escaped and the redirection target is
unquoted; update the script to HTML-escape special characters (&, <, >, ", ') in
NAME and LABELS (e.g., create a small function that replaces those characters
with &amp;, &lt;, &gt;, &quot;, &#39; and call it for NAME and LABELS before
printing) and change all redirections to quote the summary file variable (use
"$GITHUB_STEP_SUMMARY" instead of $GITHUB_STEP_SUMMARY) so markup cannot be
broken and the filename with spaces is handled safely.

Comment on lines +103 to +114
echo "<tr><td colspan=6>" >> $GITHUB_STEP_SUMMARY
if [[ "$RUNNERS" -gt 0 ]]; then
for i in $(seq -f "%02g" 1 "$RUNNERS"); do
rn="${LABELS}-${i}"
if [[ -n "${RUNNER_STATUS[$rn]:-}" || "$LABELS" == "github" ]]; then
printf "🟢" >> $GITHUB_STEP_SUMMARY
else
printf "🔴 <small>(%s)</small> " "$i" >> $GITHUB_STEP_SUMMARY
fi
done
fi
echo "</td></tr>" >> $GITHUB_STEP_SUMMARY
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Don’t mark offline runners as green; use real status (+busy) and quote path

Presence in the API isn’t “online”. Render online/idle/busy vs offline.

-            echo "<tr><td colspan=6>" >> $GITHUB_STEP_SUMMARY
+            echo "<tr><td colspan=6>" >> "$GITHUB_STEP_SUMMARY"
             if [[ "$RUNNERS" -gt 0 ]]; then
               for i in $(seq -f "%02g" 1 "$RUNNERS"); do
                 rn="${LABELS}-${i}"
-                if [[ -n "${RUNNER_STATUS[$rn]:-}" || "$LABELS" == "github" ]]; then
-                  printf "🟢" >> $GITHUB_STEP_SUMMARY
-                else
-                  printf "🔴 <small>(%s)</small> " "$i" >> $GITHUB_STEP_SUMMARY
-                fi
+                status="${RUNNER_STATUS[$rn]:-}"
+                busy="${RUNNER_BUSY[$rn]:-false}"
+                if [[ "$LABELS" == "github" ]]; then
+                  icon="🟢"
+                elif [[ "$status" == "online" ]]; then
+                  icon="🟢"
+                elif [[ -n "$status" ]]; then
+                  icon="🟡"
+                else
+                  icon="🔴"
+                fi
+                [[ "$busy" == "true" ]] && icon="${icon}🔥"
+                printf "%s <small>(%s)</small> " "$icon" "$i" >> "$GITHUB_STEP_SUMMARY"
               done
             fi
-            echo "</td></tr>" >> $GITHUB_STEP_SUMMARY
+            echo "</td></tr>" >> "$GITHUB_STEP_SUMMARY"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
echo "<tr><td colspan=6>" >> $GITHUB_STEP_SUMMARY
if [[ "$RUNNERS" -gt 0 ]]; then
for i in $(seq -f "%02g" 1 "$RUNNERS"); do
rn="${LABELS}-${i}"
if [[ -n "${RUNNER_STATUS[$rn]:-}" || "$LABELS" == "github" ]]; then
printf "🟢" >> $GITHUB_STEP_SUMMARY
else
printf "🔴 <small>(%s)</small> " "$i" >> $GITHUB_STEP_SUMMARY
fi
done
fi
echo "</td></tr>" >> $GITHUB_STEP_SUMMARY
echo "<tr><td colspan=6>" >> "$GITHUB_STEP_SUMMARY"
if [[ "$RUNNERS" -gt 0 ]]; then
for i in $(seq -f "%02g" 1 "$RUNNERS"); do
rn="${LABELS}-${i}"
status="${RUNNER_STATUS[$rn]:-}"
busy="${RUNNER_BUSY[$rn]:-false}"
if [[ "$LABELS" == "github" ]]; then
icon="🟢"
elif [[ "$status" == "online" ]]; then
icon="🟢"
elif [[ -n "$status" ]]; then
icon="🟡"
else
icon="🔴"
fi
[[ "$busy" == "true" ]] && icon="${icon}🔥"
printf "%s <small>(%s)</small> " "$icon" "$i" >> "$GITHUB_STEP_SUMMARY"
done
fi
echo "</td></tr>" >> "$GITHUB_STEP_SUMMARY"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants